package com.struts2.example.model;
import com.struts2.example.action.*;

import javassist.expr.NewArray;
import java.util.*;
import java.sql.*;
import java.sql.*;


public class RegisterDao {
	
	static Connect con = null;
	
	public static int save(Register rs)
	{
		int status =0;
		String sql = "insert into user values(?,?)";
		try {
			con = new Connect();
			PreparedStatement stm = con.GetConnect().prepareStatement(sql);
			stm.setString(1, rs.getUsername());
			stm.setString(2, rs.getPassword());
			status = stm.executeUpdate();
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return status;
	}
	
	public static ResultSet check_login(Register rs)
	{
		ResultSet sl = null;
		String sql = "select * from user where username = '"+rs.getUsername()+"'";
		try {
			con = new Connect();
			Statement stm = con.GetConnect().createStatement();
			sl = stm.executeQuery(sql);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return sl ;
	}


}
